<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js"> <!--<![endif]-->
<!-- BEGIN HEAD -->

<head>
    <include file="Public:meta"/>
</head>

<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
<include file="Public:header"/>
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <include file="Public:sidebar"/>
    <!-- BEGIN PAGE -->
    <div class="page-content">
        <!-- BEGIN PAGE CONTAINER-->
        <div class="container-fluid">
            <!-- BEGIN PAGE HEADER-->
            <div class="row-fluid">
                 <!-- begin BCN -->
                <div class="row-fluid">
                    <div class="span12"><ul class="breadcrumb"><li><i class="icon-home"></i><a onfocus="blurLink(this);" href="{:U('Index/index')}">首页</a>&nbsp;<span class="icon-angle-right"></span>&nbsp;</li><li><a onfocus="blurLink(this);" href="{:U(CONTROLLER_NAME . '/index', 'kept=1')}">{$ParentPageName|default="未命名"}</a>&nbsp;<span class="icon-angle-right"></span>&nbsp;</li><li>{$PageName|default="未命名"}</li></ul></div>
                </div>
                <!-- end BCN -->
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN PAGE CONTENT-->
            <div class="row-fluid white">
                <div class="span12">
                    <!-- begin 高级搜索 -->
                    <form id="filter_form" class="form-horizontal form-common adv-search-box" method="get" action="">
                        <input name="m" type="hidden" value="{:(MODULE_NAME)}">
                        <input name="c" type="hidden" value="{:(CONTROLLER_NAME)}">
                        <input name="a" type="hidden" value="index">
                        <input name="filter" type="hidden" value="1">
                        <input name="type" type="hidden" value="{$Think.get.type}">
                        <div class="box">
                            <div class="portlet-title">
                                <div class="caption"><i class="icon-search"></i>高级搜索</div>
                                <div class="tools"><a href="javascript:;" class="collapse"></a></div>
                            </div>
                            <div class="portlet-body">
                                <div class="row-fluid">
                                    <div class="span4">
                                        <div class="control-group control-common">
                                            <label class="control-label"><span>订单状态</span></label>
                                            <div class="controls">
                                                <select name="status">
                                                    <option value="">请选择</option>
                                                    <volist name="status" id="vo" key="key">
                                                        <option value="{$key}" <if condition="$Think.get.status eq $key">selected</if>>{$vo}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="span8">
                                        <div class="control-group control-common">
                                            <label class="control-label"><span>下单时间</span></label>
                                            <div class="controls">
                                                <div class="input-append form_date date-min" data-date="2012-12-21T15:25:00Z">
                                                    <input type="text" readonly="readonly" class="m-wrap w182" name="start" value="{$Think.get.start}" placeholder="下单开始时间" />
                                                    <span class="add-on"><i class="icon-remove"></i></span>
                                                    <span class="add-on"><i class="icon-calendar"></i></span>
                                                </div>
                                                -
                                                <div class="input-append form_date date-max" data-date="2012-12-21T15:25:00Z">
                                                    <input type="text" readonly="readonly" class="m-wrap w182" name="end" value="{$Think.get.end}" placeholder="下单结束时间" />
                                                    <span class="add-on"><i class="icon-remove"></i></span>
                                                    <span class="add-on"><i class="icon-calendar"></i></span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row-fluid">
                                    <div class="span4">
                                        <div class="control-group control-common">
                                            <label class="control-label"><span>关键字</span></label>
                                            <div class="controls">
                                                <input type="text" class="m-wrap span12" value="{$Think.get.keyword}" name="keyword" placeholder="订单号/手机号/姓名">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="search-actions">
                                    <button class="btn blue" id="filter" type="submit">筛选<i class="icon-filter"></i></button>
                                    <a href="{:U(CONTROLLER_NAME.'/index')}" class="btn">重置</a>
                                </div>
                            </div>
                        </div>
                    </form>
                    <!-- end 高级搜索 -->

                    <!-- begin 操作与分页 -->
                    <div class="row-fluid ">
                        <div class="dataTables_length pull-left">
                            <form id="limit_form" name="limit_form" method="post" action="">
                                <label for="limit_num">
                                    <select class="limit_num" id="limit_num" name="limit_num">
                                    <volist name="page_limit_num" id="vo">
                                        <option <eq name="_SESSION['page_limit_num']" value="$vo"> selected="selected" </eq> value="{$vo}">{$vo}</option>
                                    </volist>
                                    </select>
                                    个记录/每个页面
                                </label>
                            </form>
                        </div>
                        <div class="btn-item pull-left">
                            <!-- begin 导出操作 -->
                             <if condition="checkAccess(CONTROLLER_NAME,'export')">
                                <notempty name="list">
                                    <a class="btn green export" href="javascript:void(0)">数据导出</a>
                                </notempty>
                            </if>
                            <if condition="checkAccess(CONTROLLER_NAME,'import')">
                                <notempty name="list">
                                    <a class="btn green import" href="javascript:void(0)">数据导入</a>
                                </notempty>
                            </if>
                            <form id="data_import" class="hide" method="post" action="{:U(CONTROLLER_NAME.'/import')}" enctype="multipart/form-data">
                                <input type="file" name="import" class="data-import">
                            </form>
                            <!-- end 导出操作 -->
                        </div>
                        <div class="dataTables_filter pull-right">
                            <form id="search_form" class="search-form" name="search_form" method="get" action="">
                                <input name="m" type="hidden" value="{:(MODULE_NAME)}">
                                <input name="c" type="hidden" value="{:(CONTROLLER_NAME)}">
                                <input name="a" type="hidden" value="{:(ACTION_NAME)}">
                                <input class="m-wrap search-input" type="text" placeholder="搜索..." name="keyword" value="{$Think.get.keyword}"/>
                                <button class="btn blue" id="search" type="submit">搜索</button><if condition="$Think.get.keyword neq ''"><a href="{:U(CONTROLLER_NAME.'/index')}" class="btn">返回<i class="icon-share-alt"></i></a></if>
                            </form>
                        </div>
                    </div>
                    <!-- end 操作与分页 -->
                    
                    <div class="portlet-body">
                        <table class="table table-striped table-hover table-bordered">
                            <thead>
                            <tr>
                                <th>订单号</th>
                                <th>拼团号</th>
                                <!-- <th>商品编码</th> -->
                                <th>商品名称</th>
                                <th>购买数量</th>
                                <th>支付金额</th>
                                <!-- <th>成本价</th>
                                <th>开团时间</th>
                                <th>开团完成时间</th>
                                <th>购买用户</th> -->
                                <th>收件人</th>
                                <th>手机号</th>
                                <th>地址</th>
                                <th>备注</th>
                                <th>支付时间</th>
                                <th>物流信息</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <notempty name="list">
                                <tbody>
                                    <volist name="list" id="vo" key="k">
                                        <tr>
                                            <td>{$vo.order_num}</td>
                                            <td>
                                                <gt name="vo.group_id" value="0">
                                                    {$vo.group_id|getTitle=###,group,group_num}
                                                <else/>
                                                    --
                                                </gt>
                                            </td>
                                            <!-- <td>{$vo.sku}</td> -->
                                            <td>{$vo.goods_name}</td>
                                            <td>{$vo.num}</td>
                                            <td>{$vo.pay_price}</td>
                                            <!-- <td>{$vo.cost_money}</td>
                                            <td>
                                                <gt name="vo.group_id" value="0">
                                                    {$vo.group_id|getTitle=###,group,crdate|date="Y-m-d H:i:s",###}
                                                <else/>
                                                    --
                                                </gt>
                                            </td>
                                            <td>
                                                <gt name="vo.group_id" value="0">
                                                    {$vo.group_id|getTitle=###,group,complete_time|date="Y-m-d H:i:s",###}
                                                <else/>
                                                    --
                                                </gt>
                                            </td>
                                            <td>{$vo.user_id|getTitle=###,member,nickname}</td> -->
                                            <td>{$vo.name}</td>
                                            <td>{$vo.phone}</td>
                                            <td>{$vo.address}</td>
                                            <td title="{$vo.message}">{$vo.message|msubstr=###,0,35}</td>
                                            <td>
                                                <if condition="$vo['is_pay'] eq 1 && $vo['is_collect_bills'] eq 0">
                                                    {$vo.pay_time|date="Y-m-d H:i:s",###}
                                                <else/>
                                                    --
                                                </if>
                                            </td>
                                            <td class="hidden-phone">
                                                <notempty name="vo.postage_name">
                                                    <div>{$vo.postage_name}</div>
                                                    <div>{$vo.postage_num}</div>
                                                </notempty>
                                            </td>
                                            <td class="hidden-phone">
                                                <switch name="vo.status">
                                                    <case value="1">待付款</case>
                                                    <case value="2">待发货</case>
                                                    <case value="3">待收货</case>
                                                    <case value="4">待评价</case>
                                                    <case value="5">已完成</case>
                                                    <case value="6">已取消</case>
                                                    <case value="7">已失效</case>
                                                    <case value="8">退款申请中</case>
                                                    <case value="9">退款中</case>
                                                    <case value="10">已拒绝</case>
                                                    <case value="11">退款完成</case>
                                                </switch>
                                            </td>
                                            <td class="hidden-phone">
                                                <div>
                                                    <eq name='vo.status' value='2'>
                                                        <if condition="checkAccess(CONTROLLER_NAME, 'send')">
                                                            <a class="btn green-stripe mini send" data-id="{$vo.id}" href="javascript:void(0);">发货</a>
                                                        </if>
                                                    </eq>
                                                    <notempty name="vo.postage_name">
                                                        <a class="btn green-stripe mini achieve" href="javascript:void(0)" data-id="{$vo['id']}" data-url="{:U(CONTROLLER_NAME.'/checkAchieve')}">物流详细</a>
                                                    </notempty>
                                                    <eq name="vo.status" value='8'>
                                                        <a class="btn green-stripe mini agree" href="javascript:;" data-id="{$vo['id']}">同意退款</a>
                                                        <a class="btn yellow-stripe mini refuse" href="javascript:;" data-id="{$vo['id']}">拒绝</a>
                                                    </eq>
                                                </div>
                                            </td>
                                        </tr>
                                    </volist>
                                </tbody>
                            </notempty>
                        </table>
                    </div>
                    <div class="pages clearfix">
                        <include file="Public:page" />
                    </div>
                </div>
            </div>
            <!-- END PAGE CONTENT-->
        </div>
        <!-- END PAGE CONTAINER-->
    </div>
    <!-- END PAGE -->
</div>
<!-- END CONTAINER -->
<div class="tips" style="display:none">
    <div class="content">
        <form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
            <div class="list">
                物流信息
                <span class="close"></span>
            </div>
            <div class="list status">
                <span>快递公司</span>
                <select name="logistics_id">
                    <option value="">请选择快递</option>
                    <volist name="coms" id="vo">
                        <option value="{$vo[0]}">{$vo[1]}</option>
                    </volist>
                </select>
                <!-- <input name="postage_name" /> -->
            </div>
            <!-- <div class="list status">
                <span>快递拼音</span>
                <input name="postage_code" placeholder="如：yuantong" />
            </div> -->
            <div class="list status">
                <span>快递单号</span>
                <input name="postage_num" />
            </div>
            <input type="hidden" name="id" value="" />
            <div class="list">
                <button type="button" class="btn blue">保存 <i class="icon-save"></i></button>
            </div>
        </form>
    </div>
</div>
<style type="text/css">
    .tips{
        position: absolute;
        top:0;
        left:0;
        width:100%;
        height: 100%;
        z-index:9999;
        color: #000;
    }
    .content{
        position: fixed;
        top:30%;
        left:30%;
        width:500px;
        height:285px;
        background: #f4f4f4;
        box-shadow:5px 2px 6px #000;
    }
    .content form{
        display: block;
        padding: 0;
        margin:0;
        width:100%;
        height:100%;
        border-radius: 8px;
    }
    .list{
        text-align: center;
        padding:15px 30px;
    }
    .list.status{
        display:flex;
        align-items: center;
    }
    .list.status span{
        display: inline-block;
        margin-right: 35px;
    }
    textarea{
        display: block;
        width:100%;
    }
</style>
<include file="Public:footer"/>
<include file="Public:js"/>
<style type="text/css">
    .table td{
        vertical-align: middle;
    }
</style>
<script type="text/javascript">
    $(function(){
         //数据导出
        $('.export').click(function(){
            var data = $('#filter_form').serialize();
            var prefix = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME,array('filter' => 1))}";
            var list = prefix.split('?');
            data = data.replace(list[1],'');

            url = "{:U(CONTROLLER_NAME.'/export')}" + data;

            window.location.href = url;
           /* url = "{:U(CONTROLLER_NAME.'/export')}";
            window.location.href = url;*/
        });

        //数据导入
        $('.import').click(function (){
            $('.data-import').trigger('click');
        });
        $('.data-import').change(function (){
            var _form = $('#data_import');
            _form.ajaxSubmit({
                type:_form.attr('method'),
                url: _form.attr('action'),
                dataType: 'json',
                success:function(json){
                    custom_alert(json.info);
                    //if(json.status==1)window.location=location;
                }
            });
            return false;
        });

        $('a.agree').click(function(){
            var id = $(this).data('id');
            custom_confirm('确认退款？',function(){
                $.ajax({
                    type:'post',
                    url:"{:U('Order/wxrefund')}",
                    data:{
                        id:id
                    },
                    dataType:'json',
                    success:function(rs){
                        custom_alert(rs.info, rs.url);
                    }
                });
            });    
            return false;
        });

        $('a.refuse').click(function(){
            var id = $(this).data('id');
            custom_confirm('确认拒绝？',function(){
                $.ajax({
                    type:'post',
                    url:"{:U('Order/refuse')}",
                    data:{
                        id:id
                    },
                    dataType:'json',
                    success:function(rs){
                        custom_alert(rs.info, rs.url);
                    }
                });
            }); 
            return false;
        });
        
        /*查看详情*/
        $('.achieve').click(function(){
            var id = $(this).attr('data-id');
            var url = $(this).attr('data-url');
            
            $('body').modalmanager('loading');
            
            $.get(url, {id: id}, function(data){
                $('#ajax-modal').html(data).modal();
            });
            return false;
        });

        $('.content form .close').on('click',function(){
            $('.tips').hide();
        });

        $('a.send').on('click',function(){
            $('input[name=id]').val($(this).data('id'));
            $('.tips').show();
        });
        $('.content button').on('click',function(){
            var preg = /\S/;
            var flag = true;
            $('.content form [name]').each(function(){
                if(!preg.test($(this).val())){
                    custom_alert('请完善' + $(this).prev().text());
                    flag = false;
                    return false;
                }
            })
            if(!flag){
                return;
            }
            $('.content form').ajaxSubmit({
                url: "{:U(CONTROLLER_NAME.'/send')}",
                dataType: 'json',
                error: function (){
                    $('.tips').hide();
                    $('body').modalmanager('loading');
                    custom_alert('提交失败，请稍后再试！', window.location);
                },
                success: function (rs) {
                    $('.tips').hide();
                    $('body').modalmanager('loading');
                    if (rs.url != '') {
                        custom_alert(rs.info, rs.url);
                    } else {
                        custom_alert(rs.info);
                    }
                },
                beforeSend: function (){
                    $('.tips').hide();
                    $('body').modalmanager('loading');
                }
            });
        });
    })
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>